package loads

import (
	"JVM/Jvmgo/GoToJVM/instructions/base"
	"JVM/Jvmgo/GoToJVM/runtimeData"
)

/*
	这里写的是fload系列命令，
	即将float类型数据从本地变量推送到操作数栈顶的字节码命令
*/

type FLOAD struct {
	base.Index8Instruction
}
type FLOAD_0 struct {
	base.NoOperandsInstruction
}
type FLOAD_1 struct {
	base.NoOperandsInstruction
}
type FLOAD_2 struct {
	base.NoOperandsInstruction
}
type FLOAD_3 struct {
	base.NoOperandsInstruction
}

func _fload(frame *runtimeData.Frame, index uint) {
	val := frame.LocalVars().GetFloat(index)
	frame.OperandStack().PushFloat(val)
}

func (self FLOAD) Execute(frame *runtimeData.Frame) {
	_aload(frame, uint(self.Index))
}
func (self FLOAD_0) Execute(frame *runtimeData.Frame) {
	_fload(frame, 0.0)
}
func (self FLOAD_1) Execute(frame *runtimeData.Frame) {
	_fload(frame, 1.0)
}
func (self FLOAD_2) Execute(frame *runtimeData.Frame) {
	_fload(frame, 2.0)
}
func (self FLOAD_3) Execute(frame *runtimeData.Frame) {
	_fload(frame, 3.0)
}
